package com.bigdata.controller;

import com.bigdata.entity.pojo.Result;
import com.bigdata.entity.NWQualityVO;
import com.bigdata.service.NWQualityService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/network")
@RequiredArgsConstructor
public class NWQualityController {

    private final NWQualityService nwQualityService;

    @GetMapping("/quality")
    public Result<NWQualityVO> getNetworkQuality() {
        try {
            log.info("接收到网络质量统计请求");
            NWQualityVO data = nwQualityService.getNetworkQualityStats();
            log.info("处理完成，返回数据: {}", data);
            return Result.success(data);
        } catch (Exception e) {
            log.error("获取网络质量统计数据失败", e);
            return Result.error("获取网络质量统计数据失败");
        }
    }
}